prepare("SELECT * FROM questions WHERE exam_id = ? ORDER BY id"); $stmt->execute([$exam_id]); $questions = $stmt->fetchAll(PDO::FETCH_ASSOC); // Handle question deletion if (isset($_GET['delete_question'])) { $question_id = sanitize_input($_GET['delete_question']); try { $stmt = $pdo->prepare("DELETE FROM questions WHERE id = ?"); $stmt->execute([$question_id]); // Update exam question count $stmt = $pdo->prepare("UPDATE exams SET total_questions = (SELECT COUNT(*) FROM questions WHERE exam_id = ?) WHERE id = ?"); $stmt->execute([$exam_id, $exam_id]); $success = "Question deleted successfully!"; redirect("view_questions.php?exam_id=$exam_id"); } catch (PDOException $e) { $error = "Error deleting question: " . $e->getMessage(); } } ?> View Questions - <?php echo htmlspecialchars($exam['name']); ?>
← Back to Exams
0): ?> $question): ?>
Q:
mark 1 ? 's' : ''; ?>
$question['option_a'], 'B' => $question['option_b'], 'C' => $question['option_c'], 'D' => $question['option_d'] ]; foreach ($options as $letter => $option): if (!empty($option)): ?>
. ✓ Correct Answer
✏️ Edit

No Questions Added Yet

Upload questions using the Excel upload feature or add them manually.

📤 Upload Questions